{% import "components/paginator.html" as paginator with context %} {% import
"components/record.html" as record with context %} {% import
"components/problem.html" as problem with context %} {% import
"components/nothing.html" as nothing with context %}
{% macro renderDiff(pdoc) %}
{% set diffItems = ["入门","普及-","普及/提高-","普及+/提高","提高+/省选-","省选/NOI-","NOI/NOI+/CTSC"] %}
{% set _items = "" %}
{%- for tag in pdoc['tag'] -%}
{%- if tag in diffItems -%}
{% set _items= tag %}
{%- endif -%}
{%- endfor -%}
        {% set diffclass="" %}
        {% if _items == "入门" %} 
        {% set diffclass="background-color:#fe4c61 !important;color:white !important" %}
      {% endif %}
        {% if _items == "普及-" %} 
        {% set   diffclass =  "background-color:#f39c11 !important;color:white !important;" %} 
      {% endif %}
        {% if _items == "普及/提高-" %} 
        {% set diffclass="background-color:#ffc116 !important;color:white !important" %} 
      {% endif %}
        {% if _items == "普及+/提高" %} 
        {% set diffclass="background-color:#52c41a !important;color:white !important" %} 
      {% endif %}
        {% if _items == "提高+/省选-" %}
        {% set diffclass="background-color:#3498db !important;color:white !important" %}
      {% endif %}
         {% if _items == "省选/NOI-" %} 
         {% set diffclass="background-color:#9d3dcf !important;color:white !important" %}
      {% endif %}
        {% if _items == "NOI/NOI+/CTSC" %} 
        {% set diffclass="background-color:#0e1d69 !important;color:white !important" %}
      {% endif %}
      {% set _w = '"' if _items and _items.includes(' ') else '' %}
          <a
            class="problem__tag-link"
            style="border-radius:0.2em;
              {{ diffclass }}
            "
            href="{{ url('problem_main', query={q:'category:'+_w+_items+_w}) }}"
          >
            {{ _items or lib.difficulty(pdoc.nSubmit, pdoc.nAccept)
            or _('(None)') }}
          </a>
{% endmacro %}
<div data-fragment-id="problem_list">
  {% if not pdocs.length %} {{ nothing.render('Sorry, there are no problems in
  the problem set.') }} {% else %} {{ paginator.render(page, ppcount,
  position='top', add_qs=('q=' + qs if qs else '')) }}
  <table class="data-table hide-problem-tag">
    <colgroup>
      <col class="col--checkbox display-mode-hide" />
      <col class="col--pid display-mode-hide" />
      {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
      <col class="col--status edit-mode-hide" />
      {% endif %}
      <col class="col--name" />
      <col class="col--ac-tried" />
      <col class="col--difficulty" style="width:8rem;" />
    </colgroup>
    <thead>
      <tr>
        <th class="col--checkbox display-mode-hide">
          <label class="compact checkbox">
            <input
              type="checkbox"
              name="select_all"
              data-checkbox-toggle="problem"
            />
          </label>
        </th>
        <th class="col--pid display-mode-hide">{{ _('ID') }}</th>
        {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
        <th class="col--status record-status--border edit-mode-hide">
          {{ _('Status') }}
        </th>
        {% endif %}
        <th class="col--name">
          {{ _('Problem') }}
          <span class="nojs--hide toggle-tag tag--hide"
            >{{ _('Show tags') }}</span
          >
          <span class="nojs--hide toggle-tag notag--hide"
            >{{ _('Hide tags') }}</span
          >
        </th>
        <th class="col--ac-tried">{{ _('AC') }} / {{ _('Tried') }}</th>
        <th class="col--difficulty" style="width:8rem;">
          {{ _('Difficulty') }}
        </th>
      </tr>
    </thead>
    <tbody>
      {%- for pdoc in pdocs -%} {% set psdoc = psdict[pdoc.docId] %}
      <tr data-pid="{{ pdoc.docId }}">
        <td class="col--checkbox display-mode-hide">
          <label class="compact checkbox">
            <input
              type="checkbox"
              data-checkbox-group="problem"
              data-checkbox-range
            />
          </label>
        </td>
        <td class="col--pid display-mode-hide">{{ pdoc.docId }}</td>
        {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %} {% if psdoc['rid']
        %} {{ record.render_status_td(psdoc, rid_key='rid',
        class="edit-mode-hide", allDomain=pdoc.domainId!==handler.args.domainId)
        }} {% else %}
        <td class="col--status record-status--border edit-mode-hide"></td>
        {% endif %} {% endif %}
        <td
          class="col--name col--problem-name"
          data-star-action="{{ url('problem_detail', pid=pdoc.docId) }}"
          {%
          if
          handler.user.hasPriv(PRIV.PRIV_USER_PROFILE)
          %}
          data-star="{{ psdoc.star }}"
          {%
          endif
          %}
        >
          {{ problem.render_problem_title(pdoc) }}
        </td>
        <td class="col--ac-tried">{{ pdoc.nAccept }} / {{ pdoc.nSubmit }}</td>
        <td class="col--difficulty" style="padding-left:0;padding-right:0;width:8rem;line-height:1em;">
        {{ renderDiff(pdoc) }}
        </td>
      </tr>
      {%- endfor -%}
    </tbody>
  </table>
  {{ paginator.render(page, ppcount, add_qs=('q=' + qs if qs else '')) }} {%
  endif %}
</div>
